package com.qqb.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 跨域问题
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {

        registry.addMapping("/**")
                //允许的请求域名
                .allowedOrigins("*")
                //允许cookie
                .allowCredentials(true)
                //允许的请求方式
                .allowedMethods("GET", "POST", "DELETE", "PUT")
                //允许的header属性
                .allowedHeaders("*")
                // 允许的跨域时间
                .maxAge(3000);
    }
}
